package oop.day08;

import java.util.Timer;

public class TestOop {
    public static void main(String[] args) {
        Student s1 = new Student();
        s1.age=1;
        s1.name="莉莉";
        s1.skinPro="雪白";
        System.out.println(s1.age);
        System.out.println(s1.name);
        s1.sleep();
        s1.study();
        s1.eat();

        Student s2 = new Student();
        s2.age=2;
        s2.name="红红";
        System.out.println(s2.age);
        System.out.println(s2.name);
        s2.sleep();
        s2.study();

        Student s3 = new Student("大卫",17);
        s3.skinPro="黝黑";
        s3.costSkin();
        System.out.println(s3.age);
        s3.swim();
        Student s4 = new Student();

        Person p1 = new Person("李万福",78);
        p1.sleep();
        p1.eat();

       // p1.study();
        Person p2 = new Person("王富贵",101);
        p2.sleep();
        p2.eat();

       // Skin skin = new Skin();

      //  Swim swim = new Swim() ;

        Person p3 = new Student();// 向上造型
        p3.sleep();
        p3.eat();

        Swim p4 = new Student();
        p4.swim();

        Student s5= (Student) p3;
        s5.swim();
        s5.eat();
        s5.sleep();

        Student s6= (Student) p4;
        s6.study();
        s6.eat();
        s6.sleep();
        s6.swim();


        Person[] persons=  new Person[5];
        persons[0]=p1;
        persons[1]=p2;
        persons[2]=s6;
        persons[0].eat();

        //  Swim swim = new Swim() ;
       // Swim swim =new SwimSun();
       // swim.swim();
        // 匿名内部类
       Swim swim =  new Swim(){
            int a=5;
            @Override
            public void swim() {
                System.out.println("TestOop.swim");
            }
        };
       swim.swim();

   Skin s=  new Skin(){
         int master;
         @Override
         public void costSkin() {
             System.out.println("TestOop.costSkin");
         }
     };

    s.price=89;
    s.costSkin();
        System.out.println("------------");

    Timer timer = new Timer();

// JAVA中提供的一个定时任务处理类
      /* TimerTask timerTask = new TimerTask() {

           @Override
           public void run() {
               System.out.println("定时任务执行");
           }
       };

        timer.schedule(timerTask,1000,1000);*/
        timer.schedule(new TimerTaskSun(),0,1000);



    }
}
